function verify_recaptcha($recaptcha_response) {
global $recaptcha_v3_secret_key;
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_v3_secret_key . '&response=' . $recaptcha_response);
$recaptcha = json_decode($recaptcha);
return (isset($recaptcha->score) && $recaptcha->score >= 0.5) ? true : false;
}
function site_config($name) {
$result = db_query("SELECT * FROM config_site WHERE name = '".$name."'", 0);
return $result['value'];
}
function sanitize_slug($input) {
$output = preg_replace('/[^\w-]/', '', $input);
return $output;
}
/**************************************************************************/
/**************************************************************************/
function get_navigation($options = array()) {
$navigation = array();
$parent = (!isset($options['parent'])) ? 0 : $options['parent'];
$items = db_query("SELECT id, parent, nav_title, slug, redirect_type, redirect_url, template, banner, fa_icon FROM pages WHERE parent = ".$parent." AND deleted = 0 AND hide_page = 0 ORDER BY sort");
foreach ($items as $item) {
if ($parent == 0) {
$slugs = array();
} else {
$slugs = (isset($options['slugs'])) ? $options['slugs'] : array();
if (count($slugs) == 0) {
$parent = db_query("SELECT * FROM pages WHERE id = ".$item['parent'], 0);
$slugs[] = $parent['slug'];
}
}
$slugs[] = $item['slug'];
// Decode banner
$item['banner'] = json_decode($item['banner'], TRUE);
if ($item['redirect_type'] == "external") {
$item['url'] = $item['redirect_url'];
$item['target'] = "_blank";
} else if ($item['redirect_type'] == "internal") {
$item['url'] = $item['redirect_url'];
$item['target'] = "";
} else {
$item['url'] = str_replace('home/', '', '/'.implode('/', $slugs).'/');
$item['target'] = "";
}
$navigation[$item['id']] = $item;
$navigation[$item['id']]['children'] = get_navigation(array("parent" => $item['id'], "slugs" => $slugs));
$dynamic_menu_function = $item['template'].'_nav';
if (function_exists($dynamic_menu_function)) {
$navigation[$item['id']]['children'] = array_merge($navigation[$item['id']]['children'], $dynamic_menu_function(array('real_slugs' => $slugs)));
}
}
return $navigation;
}
/*****************************************************************************/
/* GET PAGE */
/****************************************************************************/
function get_page($uri) {
$page = array();
$page['full_url'] = str_replace('/index.php', '', 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); /* includes dynamic */
// $page outline
$page['pretty_url'] = '';
$page['uri_position'] = 0;
$page['content'] = array();
$page['section'] = array();
$page['breadcrumbs'] = array(); /* make sure your individual dynamic views (widgets) also build upon the breadcrumbs */
// Find Page Location
$show_404_page = false;
$last_found_page = array();
$page_ids = array();
$real_pages = array(); /* defines the real pages vs. dynamic widget content */
// NOTE: Your widgets should control the 404 for dynamic content
$uri_position = 0;
$parent = 0; /* make sure we stay in the right "directory" */
$found_one = false;
$rebuild_uri = array(); /* we just use this as a shortcut for the breadcrumbs */
foreach ($uri as $key => $slug) {
$rebuild_uri[] = $slug;
$lookup_page = db_query("SELECT * FROM pages WHERE deleted = 0 AND parent = $parent AND slug = '$slug'", 0);
if (isset($lookup_page['id']) && $lookup_page['id'] > 0) {
if ($lookup_page['parent'] == 0) {
$page['section'] = $lookup_page; /* set section data */
}
$page['breadcrumbs'][] = array("nav_title" => $lookup_page['nav_title'], "url" => '/'.implode('/', $rebuild_uri).'/');
$page_ids[] = $lookup_page['id'];
$real_pages[] = $lookup_page['slug'];
$last_found_page = $lookup_page;
$page['uri_position'] = $uri_position;
$uri_position++;
$parent = $lookup_page['id']; /* reset parent */
} else {
// Initial 404 Page Search
if ($key == 0 || $last_found_page['template'] == "default") {
$show_404_page = true;
break; /* Kill loop */
}
}
}
if ($show_404_page == true) {
$page['not_found'] = true;
} else {
/* if the page should just redirect by default, do that here */
if ($last_found_page['redirect_type'] != "regular") {
header("Location: ".$last_found_page['redirect_url']);
exit;
}
/* Pretty URL so you can link dynamic content to the last real page without it being static */
$page['pretty_url'] = '/'.implode('/', $real_pages).'/';
$page = array_merge($last_found_page, $page);
// Get Page Content
$page['content'] = db_query("SELECT * FROM page_content_rows WHERE page_id = ".$page['id']." AND deleted = 0 AND hidden = 0 ORDER BY sort");
// IF PARENT - Redirect to First Child if No Content / Page Template == default
if (($last_found_page['parent'] == 0) && count($page['content']) == 0 && ($last_found_page['template'] == "default")) {
$get_child = db_query("SELECT * FROM pages WHERE parent = ".$page['id']." AND deleted = 0 ORDER BY sort LIMIT 1", 0);
if ($get_child['slug'] > "") {
header("Location: ".$page['pretty_url'].$get_child['slug']);
exit;
}
}
// Sub Navigation
$page['section']['subnav'] = get_navigation(array("parent" => $page['section']['id'], "slugs" => array($page['section']['slug'])));
}
return $page;
}
/*************************************************/
/* Determine Parent */
/*************************************************/
function find_parent($uri) {
global $not_found_page_404;
$found_one = false;
$parent_id = 0;
$parents[] = array();
foreach ($uri as $page) {
if (!empty($page)) {
$get_pages = db_query("SELECT * FROM pages WHERE parent = $parent_id");
foreach ($get_pages as $row) {
if ($page == $row['slug']) {
$parent_id = $row['id'];
$parents[] = $row['id'];
$found_one = true;
}
}
// if we still can't find anything return 404
if ($found_one == false) {
$parents[] = $not_found_page_404;
}
}
}
return $parents;
}
/*************************************************/
/* Lookup Page by id */
/*************************************************/
function get_url_by_id($id) {
global $main_db;
$main_db->query("SET @depth := 0;");
echo "here";
$main_db->query("SET @parent := 138;");
echo "here2";
$get_url=db_query("SELECT GROUP_CONCAT(slug ORDER BY depth DESC SEPARATOR '/') AS url
FROM (
SELECT id, parent, slug, depth
FROM (
SELECT id, parent, slug,
@depth := @depth + 1 AS depth
FROM (
SELECT id, parent, slug
FROM pages
WHERE id = @parent AND deleted <> 1
UNION ALL
SELECT p.id, p.parent, p.slug
FROM pages p
JOIN pages ph ON p.id = ph.parent
WHERE ph.id = @parent AND p.deleted <> 1
) AS PageHierarchy
) AS subquery
) AS final_query;",0);
if (isset($get_url['url']) && !empty($get_url['url'])) {
echo $get_url['url'];
return "/".$get_url['url']."/";
} else {
return false;
}
}
/*************************************************/
/* Shortcodes */
/*************************************************/
// the ability to look for shortcodes {{function_name value}}
function parse_content($input) {
$output = $input;
$shortcode_asks = array();
preg_match_all(
"#{{([^}]*?)}}#",
$output,
$shortcode_asks, PREG_PATTERN_ORDER
);
foreach ($shortcode_asks[0] as $shortcode) {
$split_shortcode = explode(' ', str_replace(['{','}'], '', $shortcode), 2);
$shortcode_function = $split_shortcode[0];
$shortcode_options = $split_shortcode[1];
if (function_exists($shortcode_function)) {
$replace_value = call_user_func($shortcode_function, $shortcode_options);
$output = str_replace($shortcode, $replace_value, $output);
}
}
return $output;
}
// email parser
// called by shortcode {{encrypt_email email@email.com}} in content
function encrypt_email($email, $label = '', $classes = '', $subject = '') {
$split_email = explode('@', $email);
if (empty($label)) $label = $split_email[0]."@".$split_email[1];
$encrypt_email = "
".$label."
";
return $encrypt_email;
}
/*************************************************/
/* Social Feeds */
/*************************************************/
function find_hyperlinks($s) {
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '$1', $s);
}
function find_www($s) {
return preg_replace('@(www.([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '$1', $s);
}
function twitter_username_link($s) {
return preg_replace("/@(\w+)/", "@\\1", $s);
}
function twitter_hashtag_link($s) {
return preg_replace('/#([\\d\\w]+)/', '$0', $s);
}
function facebook_feed($options = array()) {
require_once('assets/plugins/facebook/facebook.php');
$config = array();
$config['appId'] = '464039380296913';
$config['secret'] = '68ba2a0837e144d8b0a80a04754d7fd8';
$facebook_api = new Facebook($config);
$facebook = db_query("SELECT * FROM social_feeds WHERE type = 'facebook'", 0);
$facebook_feed = json_decode(stripslashes($facebook['feed']), true);
$count = 0;
$output = array();
foreach ($facebook_feed as $item) { $count++;
$item['message'] = (isset($item['message'])) ? find_hyperlinks($item['message']) : '';
$output[] = $item;
if (isset($options['limit']) && $options['limit'] == $count) break;
}
return $output;
}
function instagram_feed($options = array()) {
$instagram = db_query("SELECT * FROM social_feeds WHERE type = 'instagram'", 0);
$instagram_feed = json_decode(stripslashes($instagram['feed']), true);
$count = 0;
$output = array();
foreach ($instagram_feed as $item) { $count++;
$item['caption']['text'] = find_hyperlinks($item['caption']['text']);
$output[] = $item;
if (isset($options['limit']) && $options['limit'] == $count) break;
}
return $output;
}
function twitter_feed($options = array()) {
$twitter = db_query("SELECT * FROM social_feeds WHERE type = 'twitter'", 0);
$twitter_feed = json_decode($twitter['feed'], true);
$count = 0;
$output = array();
foreach ($twitter_feed as $item) { $count++;
$item['text'] = twitter_username_link(twitter_hashtag_link(find_hyperlinks($item['text'])));
$output[] = $item;
if (isset($options['limit']) && $options['limit'] == $count) break;
}
return $output;
}
function removeCommonWords($input){
$commonWords = array('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero');
return preg_replace('/\b('.implode('|',$commonWords).')\b/','',$input);
}
function clean_url_from_title($title) {
return str_replace(' ', '-', preg_replace('!\s+!', ' ', removeCommonWords(strtolower(preg_replace("/[^A-Za-z0-9 ]/", '', $title)))));
}
?>
include __DIR__ . "/../plugins/postmark/Postmark.php";
define('POSTMARKAPP_API_KEY', '011613bf-76ab-483b-b1b1-064fd6f88f4e');
// This was redesigned to be able to handle multiple from addresses
function smtp_mail($options = array()) {
//$to, $subject, $message, $replyto = false, $cc = false
$from = (isset($options['from'])) ? $options['from'] : 'web@m2columbus.com';
// init
$email = new Mail_Postmark();
// from address
if(is_array($from)){
$email->from($from[0], $from[1]);
}else{
$email->from($from);
}
// subject
$email->subject($options['subject']);
// message
$email->messageHtml($options['message']);
// to
$to = explode(",", $options['to']);
foreach ($to as $e) $email->addTo(trim($e));
// reply to
if (isset($options['replyto'])) $email->replyTo($options['replyto']);
if (isset($options['cc'])) $email->addCc($options['cc']);
// send
$mail = $email->send();
}
?>
Parse error: Unmatched '}' in /home/s1uwpxj5cnpn/public_html/compliancesolutionschampionship.com/assets/views/home.php on line 215